package com.malphite.mongodemo.mongo;

import com.mongodb.WriteConcern;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoDatabase;

public class Mongo1Connection {



    public static void main(String[] args) {
        String url = "mongodb://127.0.0.1:27017";
        String databaseName = "test";
        MongoClient mongoClient = MongoClients.create(url);
        MongoDatabase database = mongoClient.getDatabase(databaseName);
        WriteConcern writeConcern = database.getWriteConcern();
        System.out.println(writeConcern);
    }

    public static MongoDatabase getDataBase(String dataBaseName){
        String url = "mongodb://127.0.0.1:27017";
        MongoClient mongoClient = MongoClients.create(url);
        MongoDatabase database = mongoClient.getDatabase(dataBaseName);
        return database;

    }
}
